require.config({
    paths:{
        "ajax":"../../../commonPort/ajax",
        "reder":"./reder",
        "get":"../common/get",
        "rederer":"./rederer"

        
    }
})
require([
    "ajax",
    "reder",
    "get",
    "rederer"

],function(ajax,reder,$,rederer){
    
        console.log(1);
  ajax.get({
   
    url:"/student",
    data:{
        start:$.$(".pai").value*(num-1),
        end:$.$(".pai").value*num
    },
    callback:function(data){
        var arr = data["data"].list
        //默认显示页数
        var  num = 1,num2 =10;
        //截取默认显示数据
        var brr = arr.slice($.$(".pai").value*(num-1),$.$(".pai").value*num)
        //渲染页面数据
        reder(brr)
        rederer(Math.ceil(arr.length/num2),num)
        //添加给导航事件
        $.$(".top").onchange =function(e){
             
            num2 = e.target.value
             brr = arr.slice($.$(".pai").value*(num-1),$.$(".pai").value*num)
            reder(brr)
            rederer(Math.ceil(arr.length/num2),num)
            
        }
        //渲染底部
        $.$(".btm").onclick =function(e){
            if (e.target.id === "a") {
                num = 1;
            }
            if (e.target.id === "c") {
                num--
                if(num <= 0){
                    num = 1
                }
            }
            if (e.target.id === "d") {
                num++
                if(num >=  Math.ceil(arr.length/num2)){
                    num =  Math.ceil(arr.length/num2)
                }
            }
            if (e.target.id === "b") {
                num = Math.ceil(arr.length/num2);
            }
            if (e.target.nodeName=== "SPAN") {
                num = e.target.innerHTML
            }
            brr = arr.slice($.$(".pai").value*(num-1),$.$(".pai").value*num)
            reder(brr)
            rederer(Math.ceil(arr.length/num2),num)
            
        }

    }
})
  
    
       

})